Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit e6f8e762aaad3031406ef07641ecf7be92870b8b


Parents : 96300a8
Author : Sudo-Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-01-01T18:36:12-06:00

feat(docker, nginx): optimize Dockerfile for frontend build and enhance demo server configuration with mock files and improved WebSocket feedback

Changes

2 files changed, 32 insertions(+), 6 deletions(-)

M nginx.demo.conf +29 -5

Diff

diff --git a/Dockerfile.demo b/Dockerfile.demo
index 9221ca8d..afa8ca9c 100644
--- a/Dockerfile.demo
+++ b/Dockerfile.demo
@@ -8,7 +8,9 @@ FROM node:${NODE_VERSION}-alpine@${NODE_ALPINE_SHA256} AS build-frontend
WORKDIR /src
COPY package.json vite.config.js pnpm-lock.yaml tailwind.config.js postcss.config.js ./
-COPY meshchatx ./meshchatx
+# Copy only the frontend source and version info to speed up builds and reduce image size
+COPY meshchatx/src/frontend ./meshchatx/src/frontend
+COPY meshchatx/src/version.py ./meshchatx/src/version.py
RUN corepack enable && corepack prepare pnpm@latest --activate

diff --git a/nginx.demo.conf b/nginx.demo.conf
index 7b2e9b8c..b6db2704 100644
--- a/nginx.demo.conf
+++ b/nginx.demo.conf
@@ -24,10 +24,29 @@ server {
try_files $uri =404;
}
- # Handle manifest.json and service-worker.js specifically
- location ~* (manifest\.json|service-worker\.js) {
+ # Mocking missing critical files for demo stability
+ location = /manifest.json {
add_header Cache-Control "no-cache";
- try_files $uri =404;
+ add_header Content-Type application/json;
+ try_files $uri @mock_manifest;
+ }
+ location @mock_manifest {
+ return 200 '{"name": "MeshChat Demo", "short_name": "MeshChat", "start_url": "/", "display": "standalone", "icons": [{"src": "/favicons/favicon-512x512.png", "sizes": "512x512", "type": "image/png"}]}';
+ }
+
+ location = /service-worker.js {
+ add_header Cache-Control "no-cache";
+ add_header Content-Type application/javascript;
+ try_files $uri @mock_sw;
+ }
+ location @mock_sw {
+ return 200 '// Mock Service Worker\nself.addEventListener("fetch", (event) => {});';
+ }
+
+ # Mock Codec2 scripts to prevent load failures in demo mode
+ location ^~ /assets/js/codec2-emscripten/ {
+ add_header Content-Type application/javascript;
+ try_files $uri =200;
}
# Gzip compression
@@ -215,6 +234,7 @@ server {
add_header Content-Type application/json;
}
+ # Improved WebSocket handler
location /ws {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
@@ -224,8 +244,12 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
- # In demo mode, there is no WebSocket backend service.
- # This block is configured to support WSS upgrades from a reverse proxy.
+ # In demo mode, returning 200 for non-WS requests provides better feedback
+ if ($http_upgrade != "websocket") {
+ return 200 "WebSocket Mock Endpoint (Active)";
+ }
+
+ # For actual WS connection attempts, we still return 503 as there is no backend server.
return 503;
}


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────